using System;
using System.Collections.Generic;
using System.Text;
using VSSDKAssist.Assets.ValueProviders.Base;
using EnvDTE;

namespace VSSDKAssist.Assets.ValueProviders.VisualStudio
{
	/// <summary>
	/// Value provider for the selected ProjectItem
	/// </summary>
	public class CurrentlySelectedProjectItemValueProvider : ValueProviderBase
	{
		#region Overrides
		/// <summary>
		/// Called when [begin recipe].
		/// </summary>
		/// <param name="currentValue">The current value.</param>
		/// <param name="newValue">The new value.</param>
		/// <returns></returns>
		public override bool OnBeginRecipe(object currentValue, out object newValue)
		{
			newValue = null;

			if((currentValue == null) && (this.ExecutionStage != Stage.OnBeforeActions))
			{
				if(VisualStudio.SelectedItems.Count == 1)
				{
					newValue = VisualStudio.SelectedItems.Item(1).ProjectItem as ProjectItem;
					return true;
				}
			}

			return false;
		}
		#endregion
	}
}